<?xml version="1.0" encoding="UTF-8"?>
<project name="FTPUpload" default="all">
  
  
  <property file="FTPUpload.properties"/>
  <!-- Uncomment the following property if no tests compilation is needed -->
  <!-- 
  <property name="skip.tests" value="true"/>
   -->
  
  <!-- Compiler options -->
  
  <property name="compiler.debug" value="on"/>
  <property name="compiler.generate.no.warnings" value="off"/>
  <property name="compiler.args" value=""/>
  <property name="compiler.max.memory" value="128m"/>
  <patternset id="ignored.files">
    <exclude name="**/CVS/**"/>
    <exclude name="**/SCCS/**"/>
    <exclude name="**/RCS/**"/>
    <exclude name="**/rcs/**"/>
    <exclude name="**/.DS_Store/**"/>
    <exclude name="**/.svn/**"/>
    <exclude name="**/.pyc/**"/>
    <exclude name="**/.pyo/**"/>
    <exclude name="**/*.pyc/**"/>
    <exclude name="**/*.pyo/**"/>
    <exclude name="**/.git/**"/>
    <exclude name="**/*.hprof/**"/>
    <exclude name="**/_svn/**"/>
    <exclude name="**/.sbas/**"/>
    <exclude name="**/.IJI.*/**"/>
    <exclude name="**/vssver.scc/**"/>
    <exclude name="**/vssver2.scc/**"/>
    <exclude name="**/.hg/**"/>
    <exclude name="**/*.orig/**"/>
    <exclude name="**/*.lib/**"/>
    <exclude name="**/*~/**"/>
  </patternset>
  <patternset id="library.patterns">
    <include name="*.war"/>
    <include name="*.ear"/>
    <include name="*.zip"/>
    <include name="*.swc"/>
    <include name="*.egg"/>
    <include name="*.jar"/>
  </patternset>
  <patternset id="compiler.resources">
    <include name="**/?*.properties"/>
    <include name="**/?*.xml"/>
    <include name="**/?*.gif"/>
    <include name="**/?*.png"/>
    <include name="**/?*.jpeg"/>
    <include name="**/?*.jpg"/>
    <include name="**/?*.html"/>
    <include name="**/?*.dtd"/>
    <include name="**/?*.tld"/>
    <include name="**/?*.ftl"/>
  </patternset>

  <dirname property="module.FTPUpload-common.basedir" file="${ant.file}"/>
  
  
  
  <property name="compiler.args.FTPUpload-common" value="${compiler.args}"/>
  
  <property name="FTPUpload-common.output.dir" value="${module.FTPUpload-common.basedir}/FTPUpload-common/classes"/>
  <property name="FTPUpload-common.testoutput.dir" value="${module.FTPUpload-common.basedir}/FTPUpload-common/classes"/>
  
  <path id="FTPUpload-common.module.bootclasspath">

  </path>
  
  <path id="FTPUpload-common.module.production.classpath">
    <pathelement location="W:/annotations.jar"/>

  </path>
  
  <path id="FTPUpload-common.runtime.production.module.classpath">
    <pathelement location="${FTPUpload-common.output.dir}"/>
    <pathelement location="W:/annotations.jar"/>
  </path>
  
  <path id="FTPUpload-common.module.classpath">
    <pathelement location="${FTPUpload-common.output.dir}"/>
    <pathelement location="W:/annotations.jar"/>
  </path>
  
  <path id="FTPUpload-common.runtime.module.classpath">
    <pathelement location="${FTPUpload-common.output.dir}"/>
    <pathelement location="W:/annotations.jar"/>
  </path>
  
  
  <patternset id="excluded.from.module.FTPUpload-common">
    <patternset refid="ignored.files"/>
  </patternset>
  
  <patternset id="excluded.from.compilation.FTPUpload-common">
    <patternset refid="excluded.from.module.FTPUpload-common"/>
  </patternset>
  
  <path id="FTPUpload-common.module.sourcepath">
    <dirset dir="${module.FTPUpload-common.basedir}/FTPUpload-common">
      <include name="src"/>
    </dirset>
  </path>
  
  
  <target name="compile.module.FTPUpload-common" depends="compile.module.FTPUpload-common.production" description="Compile module FTPUpload-common"/>
  
  <target name="compile.module.FTPUpload-common.production" description="Compile module FTPUpload-common; production classes">
    <mkdir dir="${FTPUpload-common.output.dir}"/>
    <javac destdir="${FTPUpload-common.output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memorymaximumsize="${compiler.max.memory}" fork="true">
      <compilerarg line="${compiler.args.FTPUpload-common}"/>
      <bootclasspath refid="FTPUpload-common.module.bootclasspath"/>
      <classpath refid="FTPUpload-common.module.production.classpath"/>
      <src refid="FTPUpload-common.module.sourcepath"/>
      <patternset refid="excluded.from.compilation.FTPUpload-common"/>
    </javac>
    
    <copy todir="${FTPUpload-common.output.dir}">
      <fileset dir="${module.FTPUpload-common.basedir}/FTPUpload-common/src">
        <patternset refid="compiler.resources"/>
        <type type="file"/>
      </fileset>
    </copy>
  </target>
  
  <target name="clean.module.FTPUpload-common" description="cleanup module">
    <delete dir="${FTPUpload-common.output.dir}"/>
    <delete dir="${FTPUpload-common.testoutput.dir}"/>
  </target>

  <dirname property="module.web.basedir" file="${ant.file}"/>
  
  
  
  <property name="compiler.args.web" value="${compiler.args}"/>
  
  <property name="web.output.dir" value="${module.web.basedir}/web/classes"/>
  <property name="web.testoutput.dir" value="${module.web.basedir}/web/classes"/>
  
  <path id="web.module.bootclasspath">
    <!-- Paths to be included in compilation bootclasspath -->
  </path>
  
  <path id="web.module.production.classpath"/>
  
  <path id="web.runtime.production.module.classpath">
    <pathelement location="${web.output.dir}"/>
  </path>
  
  <path id="web.module.classpath">
    <pathelement location="${web.output.dir}"/>
  </path>
  
  <path id="web.runtime.module.classpath">
    <pathelement location="${web.output.dir}"/>
  </path>


  <dirname property="module.FTPUpload-agent.basedir" file="${ant.file}"/>
  <property name="compiler.args.FTPUpload" value="${compiler.args}"/>
  <property name="FTPUpload-agent.output.dir" value="${module.FTPUpload-agent.basedir}/FTPUpload-agent/classes"/>
  <property name="FTPUpload-agent.testoutput.dir" value="${module.FTPUpload-agent.basedir}/FTPUpload-agent/classes"/>
  
  <path id="FTPUpload-agent.module.bootclasspath">

  </path>
  
  <path id="FTPUpload-agent.module.production.classpath">
    <pathelement location="W:/commons-net-3.1.jar" />
    <pathelement location="W:/agent.jar"/>
    <pathelement location="W:/common-api.jar"/>
    <pathelement location="W:/agent-api.jar"/>
    <pathelement location="W:/annotations.jar"/>
    <pathelement location="${FTPUpload-common.output.dir}"/>
    <pathelement location="W:/log4j-1.2.12.jar"/>
    <pathelement location="W:/util.jar"/>
    <pathelement location="W:/openapi.jar"/>

  </path>
  
  <path id="FTPUpload-agent.runtime.production.module.classpath">
    <pathelement location="W:/commons-net-3.1.jar"/>
    <pathelement location="${FTPUpload-agent.output.dir}"/>
    <pathelement location="W:/agent.jar"/>
    <pathelement location="W:/common-api.jar"/>
    <pathelement location="W:/agent-api.jar"/>
    <pathelement location="W:/annotations.jar"/>
    <pathelement location="${FTPUpload-common.output.dir}"/>
    <pathelement location="W:/annotations.jar"/>
    <pathelement location="W:/log4j-1.2.12.jar"/>
    <pathelement location="W:/util.jar"/>
    <pathelement location="W:/openapi.jar"/>
  </path>
  
  <path id="FTPUpload-agent.module.classpath">
    <pathelement location="W:/commons-net-3.1.jar"/>
    <pathelement location="${FTPUpload-agent.output.dir}"/>
    <pathelement location="W:/agent.jar"/>
    <pathelement location="W:/common-api.jar"/>
    <pathelement location="W:/agent-api.jar"/>
    <pathelement location="W:/annotations.jar"/>
    <pathelement location="${FTPUpload-common.output.dir}"/>
    <pathelement location="W:/log4j-1.2.12.jar"/>
    <pathelement location="W:/util.jar"/>
    <pathelement location="W:/openapi.jar"/>
  </path>
  
  <path id="FTPUpload-agent.runtime.module.classpath">
    <pathelement location="W:/commons-net-3.1.jar"/>
    <pathelement location="${FTPUpload-agent.output.dir}"/>
    <pathelement location="W:/agent.jar"/>
    <pathelement location="W:/common-api.jar"/>
    <pathelement location="W:/agent-api.jar"/>
    <pathelement location="W:/annotations.jar"/>
    <pathelement location="${FTPUpload-common.output.dir}"/>
    <pathelement location="W:/annotations.jar"/>
    <pathelement location="W:/log4j-1.2.12.jar"/>
    <pathelement location="W:/util.jar"/>
    <pathelement location="W:/openapi.jar"/>
  </path>
  
  
  <patternset id="excluded.from.module.FTPUpload-agent">
    <patternset refid="ignored.files"/>
  </patternset>
  
  <patternset id="excluded.from.compilation.FTPUpload-agent">
    <patternset refid="excluded.from.module.FTPUpload-agent"/>
  </patternset>
  
  <path id="FTPUpload-agent.module.sourcepath">
    <dirset dir="${module.FTPUpload-agent.basedir}/FTPUpload-agent">
      <include name="src"/>
    </dirset>
  </path>
  
  
  <target name="compile.module.FTPUpload-agent" depends="compile.module.FTPUpload-agent.production" description="Compile module FTPUpload"/>
  
  <target name="compile.module.FTPUpload-agent.production" depends="compile.module.FTPUpload-common" description="Compile module FTPUpload; production classes">
    <mkdir dir="${FTPUpload-agent.output.dir}"/>
    <javac destdir="${FTPUpload-agent.output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memorymaximumsize="${compiler.max.memory}" fork="true">
      <compilerarg line="${compiler.args.FTPUpload}"/>
      <bootclasspath refid="FTPUpload-agent.module.bootclasspath"/>
      <classpath refid="FTPUpload-agent.module.production.classpath"/>
      <src refid="FTPUpload-agent.module.sourcepath"/>
      <patternset refid="excluded.from.compilation.FTPUpload-agent"/>
    </javac>
    
    <copy todir="${FTPUpload-agent.output.dir}">
      <fileset dir="${module.FTPUpload-agent.basedir}/FTPUpload-agent/src">
        <patternset refid="compiler.resources"/>
        <type type="file"/>
      </fileset>
    </copy>
  </target>
  
  <target name="clean.module.FTPUpload" description="cleanup module">
    <delete dir="${FTPUpload-agent.output.dir}"/>
  </target>

  <dirname property="module.FTPUpload-server.basedir" file="${ant.file}"/>
  <property name="compiler.args.FTPUpload-server" value="${compiler.args}"/>
  
  <property name="FTPUpload-server.output.dir" value="${module.FTPUpload-server.basedir}/FTPUpload-server/classes"/>
  <property name="FTPUpload-server.testoutput.dir" value="${module.FTPUpload-server.basedir}/FTPUpload-server/classes"/>
  
  <path id="FTPUpload-server.module.bootclasspath">
    <!-- Paths to be included in compilation bootclasspath -->
  </path>
  
  <path id="FTPUpload-server.module.production.classpath">
    <pathelement location="W:/common-api.jar"/>
    <pathelement location="W:/server-api.jar"/>
    <pathelement location="W:/annotations.jar"/>
    <pathelement location="W:/openapi.jar"/>
    <pathelement location="W:/spring.jar"/>
    <pathelement location="W:/util.jar"/>
    <pathelement location="${FTPUpload-common.output.dir}"/>
    <pathelement location="W:/standard.jar"/>
    <pathelement location="W:/jstl.jar"/>
  </path>
  
  <path id="FTPUpload-server.runtime.production.module.classpath">
    <pathelement location="${FTPUpload-server.output.dir}"/>
    <pathelement location="W:/common-api.jar"/>
    <pathelement location="W:/server-api.jar"/>
    <pathelement location="W:/annotations.jar"/>
    <pathelement location="W:/openapi.jar"/>
    <pathelement location="W:/spring.jar"/>
    <pathelement location="W:/util.jar"/>
    <pathelement location="${FTPUpload-common.output.dir}"/>
    <pathelement location="W:/annotations.jar"/>
    <pathelement location="W:/standard.jar"/>
    <pathelement location="W:/jstl.jar"/>
  </path>
  
  <path id="FTPUpload-server.module.classpath">
    <pathelement location="${FTPUpload-server.output.dir}"/>
    <pathelement location="W:/common-api.jar"/>
    <pathelement location="W:/server-api.jar"/>
    <pathelement location="W:/annotations.jar"/>
      <pathelement location="W:/openapi.jar"/>
      <pathelement location="W:/spring.jar"/>
      <pathelement location="W:/util.jar"/>
    <pathelement location="${FTPUpload-common.output.dir}"/>
    <pathelement location="W:/standard.jar"/>
    <pathelement location="W:/jstl.jar"/>
  </path>
  
  <path id="FTPUpload-server.runtime.module.classpath">
    <pathelement location="${FTPUpload-server.output.dir}"/>
    <pathelement location="W:/common-api.jar"/>
    <pathelement location="W:/server-api.jar"/>
    <pathelement location="W:/annotations.jar"/>
    <pathelement location="W:/openapi.jar"/>
    <pathelement location="W:/spring.jar"/>
    <pathelement location="W:/util.jar"/>
    <pathelement location="${FTPUpload-common.output.dir}"/>
    <pathelement location="W:/annotations.jar"/>
    <pathelement location="W:/standard.jar"/>
    <pathelement location="W:/jstl.jar"/>
  </path>
  
  
  <patternset id="excluded.from.module.FTPUpload-server">
    <patternset refid="ignored.files"/>
  </patternset>
  
  <patternset id="excluded.from.compilation.FTPUpload-server">
    <patternset refid="excluded.from.module.FTPUpload-server"/>
  </patternset>
  
  <path id="FTPUpload-server.module.sourcepath">
    <dirset dir="${module.FTPUpload-server.basedir}/FTPUpload-server">
      <include name="src"/>
      <include name="resources"/>
    </dirset>
  </path>
  
  
  <target name="compile.module.FTPUpload-server" depends="compile.module.FTPUpload-server.production" description="Compile module FTPUpload-server"/>
  
  <target name="compile.module.FTPUpload-server.production" depends="compile.module.FTPUpload-common" description="Compile module FTPUpload-server; production classes">
    <mkdir dir="${FTPUpload-server.output.dir}"/>
    <javac destdir="${FTPUpload-server.output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memorymaximumsize="${compiler.max.memory}" fork="true">
      <compilerarg line="${compiler.args.FTPUpload-server}"/>
      <bootclasspath refid="FTPUpload-server.module.bootclasspath"/>
      <classpath refid="FTPUpload-server.module.production.classpath"/>
      <src refid="FTPUpload-server.module.sourcepath"/>
      <patternset refid="excluded.from.compilation.FTPUpload-server"/>
    </javac>
    
    <copy todir="${FTPUpload-server.output.dir}">
      <fileset dir="${module.FTPUpload-server.basedir}/FTPUpload-server/src">
        <patternset refid="compiler.resources"/>
        <type type="file"/>
      </fileset>
      <fileset dir="${module.FTPUpload-server.basedir}/FTPUpload-server/src/buildServerResources">
        <patternset refid="compiler.resources"/>
        <type type="file"/>
      </fileset>
    </copy>
  </target>

  <target name="clean.module.FTPUpload-server" description="cleanup module">
    <delete dir="${FTPUpload-server.output.dir}"/>
    <delete dir="${FTPUpload-server.testoutput.dir}"/>
  </target>
  
  <target name="init" description="Build initialization">
    <!-- Perform any build initialization in this target -->
  </target>
  
  <target name="clean" depends="clean.module.FTPUpload-common, clean.module.FTPUpload, clean.module.FTPUpload-server, clean.artifact.agent, clean.artifact.plugin_dist, clean.artifact.web" description="cleanup all"/>
  
  <target name="build.modules" depends="init, clean, compile.module.FTPUpload-common, compile.module.FTPUpload-agent, compile.module.FTPUpload-server" description="build all modules"/>
  
  <target name="init.artifacts">
    <property name="artifacts.temp.dir" value="${basedir}/__artifacts_temp"/>
    <property name="artifact.output.agent" value="${basedir}/.idea_artifacts/Agent"/>
    <property name="artifact.output.plugin_dist" value="${basedir}/.idea_artifacts/dist"/>
    <property name="artifact.output.web" value="${basedir}/.idea_artifacts/Web"/>
    <mkdir dir="${artifacts.temp.dir}"/>
    <property name="temp.jar.path.FTPUpload.jar" value="${artifacts.temp.dir}/FTPUpload.jar"/>
    <property name="temp.jar.path.FTPUpload.zip" value="${artifacts.temp.dir}/FTPUpload.zip"/>
    <property name="temp.jar.path.FTPUpload.zip2" value="${artifacts.temp.dir}/1/FTPUpload.zip"/>
    <mkdir dir="${artifacts.temp.dir}/1"/>
    <property name="temp.jar.path.FTPUpload.jar2" value="${artifacts.temp.dir}/1/FTPUpload.jar"/>
    <property name="temp.jar.path.FTPUpload.jar3" value="${artifacts.temp.dir}/2/FTPUpload.jar"/>
    <mkdir dir="${artifacts.temp.dir}/2"/>
    <property name="temp.jar.path.FTPUpload.jar4" value="${artifacts.temp.dir}/3/FTPUpload.jar"/>
    <mkdir dir="${artifacts.temp.dir}/3"/>
  </target>
  
  <target name="clean.artifact.agent" description="clean Agent artifact output">
    <delete dir="${artifact.output.agent}"/>
  </target>
  
  <target name="clean.artifact.plugin_dist" description="clean Plugin Dist artifact output">
    <delete dir="${artifact.output.plugin_dist}"/>
  </target>
  
  <target name="clean.artifact.web" description="clean Web artifact output">
    <delete dir="${artifact.output.web}"/>
  </target>
  
  <target name="artifact.agent" depends="init.artifacts, compile.module.FTPUpload-agent, compile.module.FTPUpload-common" description="Build &apos;Agent&apos; artifact">
    <mkdir dir="${artifact.output.agent}"/>
    <jar destfile="${temp.jar.path.FTPUpload.jar}" duplicate="preserve" filesetmanifest="mergewithoutmain">
      <zipfileset dir="${FTPUpload-agent.output.dir}"/>
      <zipfileset dir="${FTPUpload-common.output.dir}"/>
    </jar>
    <copy todir="${artifact.output.agent}">
      <fileset dir="${path.variable.teamcity_root}/buildAgent"/>
    </copy>
    <mkdir dir="${artifact.output.agent}/plugins"/>
    <mkdir dir="${artifact.output.agent}/plugins/FTPUpload"/>
    <copy file="${temp.jar.path.FTPUpload.jar}" tofile="${artifact.output.agent}/plugins/FTPUpload/FTPUpload.jar"/>
  </target>
  
  <target name="artifact.plugin_dist" depends="init.artifacts, compile.module.FTPUpload-agent, compile.module.FTPUpload-common, compile.module.FTPUpload-server, compile.module.FTPUpload-common" description="Build &apos;Plugin Dist&apos; artifact">
    <mkdir dir="${artifact.output.plugin_dist}"/>
    <jar destfile="${temp.jar.path.FTPUpload.jar2}" duplicate="preserve" filesetmanifest="mergewithoutmain">
      <zipfileset dir="${FTPUpload-agent.output.dir}"/>
      <zipfileset dir="${FTPUpload-common.output.dir}"/>
    </jar>
    <zip destfile="${temp.jar.path.FTPUpload.zip2}">
      <zipfileset file="W:/commons-net-3.1.jar" prefix="FTPUpload/lib"/>
      <zipfileset file="${temp.jar.path.FTPUpload.jar2}" prefix="FTPUpload/lib"/>
    </zip>
    <jar destfile="${temp.jar.path.FTPUpload.jar3}" duplicate="preserve" filesetmanifest="mergewithoutmain">
      <zipfileset dir="${FTPUpload-server.output.dir}"/>
      <zipfileset dir="${FTPUpload-common.output.dir}"/>
      <zipfileset dir="${basedir}/FTPUpload-server/src/buildServerResources"/>
    </jar>
    <zip destfile="${temp.jar.path.FTPUpload.zip}">
      <zipfileset file="${temp.jar.path.FTPUpload.zip2}" prefix="agent"/>
      <zipfileset file="${temp.jar.path.FTPUpload.jar3}" prefix="server"/>
      <zipfileset file="${basedir}/teamcity-plugin.xml"/>
    </zip>
    <copy file="${temp.jar.path.FTPUpload.zip}" tofile="${artifact.output.plugin_dist}/FTPUpload.zip"/>
  </target>
  
  <target name="artifact.web" depends="init.artifacts, compile.module.FTPUpload-common, compile.module.FTPUpload-server" description="Build &apos;Web&apos; artifact">
    <mkdir dir="${artifact.output.web}"/>
    <jar destfile="${temp.jar.path.FTPUpload.jar4}" duplicate="preserve" filesetmanifest="mergewithoutmain">
      <zipfileset dir="${FTPUpload-common.output.dir}"/>
      <zipfileset dir="${FTPUpload-server.output.dir}"/>
    </jar>
    <mkdir dir="${artifact.output.web}/WEB-INF"/>
    <mkdir dir="${artifact.output.web}/WEB-INF/plugins"/>
    <mkdir dir="${artifact.output.web}/WEB-INF/plugins/FTPUpload"/>
    <mkdir dir="${artifact.output.web}/WEB-INF/plugins/FTPUpload/server"/>
    <mkdir dir="${artifact.output.web}/WEB-INF/plugins/FTPUpload/server/lib"/>
    <copy file="${temp.jar.path.FTPUpload.jar4}" tofile="${artifact.output.web}/WEB-INF/plugins/FTPUpload/server/lib/FTPUpload.jar"/>
    <copy file="${basedir}/teamcity-plugin.xml" tofile="${artifact.output.web}/WEB-INF/plugins/FTPUpload/teamcity-plugin.xml"/>
    <mkdir dir="${artifact.output.web}/plugins"/>
    <mkdir dir="${artifact.output.web}/plugins/FTPUpload"/>
    <copy todir="${artifact.output.web}/plugins/FTPUpload">
      <fileset dir="${basedir}/FTPUpload-server/resources/buildServerResources"/>
    </copy>
    <copy todir="${artifact.output.web}">
      <fileset dir="${path.variable.teamcity_root}/webapps/ROOT"/>
    </copy>
  </target>
  
  <target name="build.all.artifacts" depends="artifact.agent, artifact.plugin_dist, artifact.web" description="Build all artifacts">
    
    <!-- Delete temporary files -->
    <delete dir="${artifacts.temp.dir}"/>
  </target>
  
  <target name="all" depends="build.modules, build.all.artifacts" description="build all"/>
</project>